package annotation;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;

public class TestRunner {
	public static void main(String[] args) throws Exception, Exception {
		Class[] classes = { TestCase.class };
		run(classes);
	}

	private static void run(Class[] classes) throws Exception,
			IllegalAccessException {
		for (Class c : classes) {
			Object o = c.newInstance();
			Method[] ms = c.getDeclaredMethods();
			for (Method m : ms) {
				Annotation ann = m.getAnnotation(Test.class);// Test t=
																// m.getAnnotation(Test.class);则不需要下面的转型
				if (null != ann) {
					Test t = (Test) ann;
					System.out.println("id:" + t.id());
					System.out.println("desc:" + t.description());
					m.invoke(o, null);
				}
			}
		}
	}
}
